|
G' |
T |
|
|
|
|
- 1. Set VT = {VG} = { {0, 1, 2, 3, 4, 5} } and ET = ∅.
- 2. Since VT has only one vertex, choose X = VG = {0, 1, 2, 3, 4, 5}. Note that | X | = 6 ≥ 2.
|
1. |
|
|
|
- 3. Since T∖X = ∅, there is no contraction and therefore G' = G.
- 4. Choose s = 1 and t = 5. The minimum s-t cut (A', B') is ({0, 1, 2, 4}, {3, 5}) with c'(A', B') = 6.
- Set A = {0, 1, 2, 4} and B = {3, 5}.
- 5. Set VT = (VT∖X) ∪ {A ∩ X, B ∩ X} = { {0, 1, 2, 4}, {3, 5} }.
- Set ET = { ({0, 1, 2, 4}, {3, 5}) }.
- Set w( ({0, 1, 2, 4}, {3, 5}) ) = c'(A', B') = 6.
- Go to step 2.
- 2. Choose X = {3, 5}. Note that | X | = 2 ≥ 2.
|
2. |
|
|
|
- 3. {0, 1, 2, 4} is the connected component in T∖X and thus S = { {0, 1, 2, 4} }.
- Contract {0, 1, 2, 4} to form G', where
- c'( (3, {0, 1, 2 ,4}) ) = c( (3, 1) ) + c( (3, 4) ) = 4.
- c'( (5, {0, 1, 2, 4}) ) = c( (5, 4) ) = 2.
- c'( (3, 5)) = c( (3, 5) ) = 6.
- 4. Choose s = 3, t = 5. The minimum s-t cut (A', B') in G' is ( {{0, 1, 2, 4}, 3}, {5} ) with c'(A', B') = 8.
- Set A = {0, 1, 2, 3, 4} and B = {5}.
- 5. Set VT = (VT∖X) ∪ {A ∩ X, B ∩ X} = { {0, 1, 2, 4}, {3}, {5} }.
- Since (X, {0, 1, 2, 4}) ∈ ET and {0, 1, 2, 4} ⊂ A, replace it with (A ∩ X, Y) = ({3}, {0, 1, 2 ,4}).
- Set ET = { ({3}, {0, 1, 2 ,4}), ({3}, {5}) } with
- w(({3}, {0, 1, 2 ,4})) = w((X, {0, 1, 2, 4})) = 6.
- w(({3}, {5})) = c'(A', B') = 8.
- Go to step 2.
- 2. Choose X = {0, 1, 2, 4}. Note that | X | = 4 ≥ 2.
|
3. |
|
|
|
- 3. { {3}, {5} } is the connected component in T∖X and thus S = { {3, 5} }.
- Contract {3, 5} to form G', where
- c'( (1, {3, 5}) ) = c( (1, 3) ) = 3.
- c'( (4, {3, 5}) ) = c( (4, 3) ) + c( (4, 5) ) = 3.
- c'(u,v) = c(u,v) for all u,v ∈ X.
- 4. Choose s = 1, t = 2. The minimum s-t cut (A', B') in G' is ( {1, {3, 5}, 4}, {0, 2} ) with c'(A', B') = 6.
- Set A = {1, 3, 4, 5} and B = {0, 2}.
- 5. Set VT = (VT∖X) ∪ {A ∩ X, B ∩ X} = { {3}, {5}, {1, 4}, {0, 2} }.
- Since (X, {3}) ∈ ET and {3} ⊂ A, replace it with (A ∩ X, Y) = ({1, 4}, {3}).
- Set ET = { ({1, 4}, {3}), ({3}, {5}), ({0, 2}, {1, 4}) } with
- w(({1, 4}, {3})) = w((X, {3})) = 6.
- w(({0, 2}, {1, 4})) = c'(A', B') = 6.
- Go to step 2.
- 2. Choose X = {1, 4}. Note that | X | = 2 ≥ 2.
|
4. |
|
|
|
- 3. { {3}, {5} }, { {0, 2} } are the connected components in T∖X and thus S = { {0, 2}, {3, 5} }.
- Contract {0, 2} and {3, 5} to form G', where
- c'( (1, {3, 5}) ) = c( (1, 3) ) = 3.
- c'( (4, {3, 5}) ) = c( (4, 3) ) + c( (4, 5) ) = 3.
- c'( (1, {0, 2}) ) = c( (1, 0) ) + c( (1, 2) ) = 2.
- c'( (4, {0, 2}) ) = c( (4, 2) ) = 4.
- c'(u,v) = c(u,v) for all u,v ∈ X.
- 4. Choose s = 1, t = 4. The minimum s-t cut (A', B') in G' is ( {1, {3, 5}}, {{0, 2}, 4} ) with c'(A', B') = 7.
- Set A = {1, 3, 5} and B = {0, 2, 4}.
- 5. Set VT = (VT∖X) ∪ {A ∩ X, B ∩ X} = { {3}, {5}, {0, 2}, {1}, {4} }.
- Since (X, {3}) ∈ ET and {3} ⊂ A, replace it with (A ∩ X, Y) = ({1}, {3}).
- Since (X, {0, 2}) ∈ ET and {0, 2} ⊂ B, replace it with (B ∩ X, Y) = ({4}, {0, 2}).
- Set ET = { ({1}, {3}), ({3}, {5}), ({4}, {0, 2}), ({1}, {4}) } with
- w(({1}, {3})) = w((X, {3})) = 6.
- w(({4}, {0, 2})) = w((X, {0, 2})) = 6.
- w(({1}, {4})) = c'(A', B') = 7.
- Go to step 2.
- 2. Choose X = {0, 2}. Note that | X | = 2 ≥ 2.
|
5. |
|
|
|
- 3. { {1}, {3}, {4}, {5} } is the connected component in T∖X and thus S = { {1, 3, 4, 5} }.
- Contract {1, 3, 4, 5} to form G', where
- c'( (0, {1, 3, 4, 5}) ) = c( (0, 1) ) = 1.
- c'( (2, {1, 3, 4, 5}) ) = c( (2, 1) ) + c( (2, 4) ) = 5.
- c'( (0, 2) ) = c( (0, 2) ) = 7.
- 4. Choose s = 0, t = 2. The minimum s-t cut (A', B') in G' is ( {0}, {2, {1, 3, 4, 5}} ) with c'(A', B') = 8.
- Set A = {0} and B = {1, 2, 3 ,4 ,5}.
- 5. Set VT = (VT∖X) ∪ {A ∩ X, B ∩ X} = { {3}, {5}, {1}, {4}, {0}, {2} }.
- Since (X, {4}) ∈ ET and {4} ⊂ B, replace it with (B ∩ X, Y) = ({2}, {4}).
- Set ET = { ({1}, {3}), ({3}, {5}), ({2}, {4}), ({1}, {4}), ({0}, {2}) } with
- w(({2}, {4})) = w((X, {4})) = 6.
- w(({0}, {2})) = c'(A', B') = 8.
- Go to step 2.
- 2. There does not exist X∈VT with | X | ≥ 2. Hence, go to step 6.
|
6. |
|
|
- 6. Replace VT = { {3}, {5}, {1}, {4}, {0}, {2} } by {3, 5, 1, 4, 0, 2}.
- Replace ET = { ({1}, {3}), ({3}, {5}), ({2}, {4}), ({1}, {4}), ({0}, {2}) } by { (1, 3), (3, 5), (2, 4), (1, 4), (0, 2) }.
- Output T. Note that exactly | V | − 1 = 6 − 1 = 5 times min-cut computation is performed.
|
The Gusfield's algorithm can be used to find a Gomory–Hu tree without any vertex contraction in the same running time-complexity, which simplifies the implementation of constructing a Gomory–Hu Tree.